by DL Keeshin
April 21, 2025
In my last post, I described how the kDS Discovery App is now using Jinja2 to manage dynamic prompts and templates. Today, I want to talk about a behind-the-scenes piece that’s just as important: how we deploy the app’s PostgreSQL database in a clean, repeatable, and efficient way.
To get a new, up-to-date version of the database running, we rely on two key scripts. One handles the structural backbone of the database—schemas, tables, constraints—while the other focuses on the programmable components like stored procedures, views, and functions that exist in the development environment.
We use dbdiagram.io from Holistics as our modeling tool. It’s an online schema designer that lets you visually lay out your database using their Database Markup Language (DBML). It’s readable, intuitive, and interestingly, LLMs like ChatGPT and Claude AI understand it. The diagram at the top of this blog is generated with it. The tool is very affordable and has a FREE plan that would meet the needs of many users.
The export from dbdiagram.io gives us all the basics:
Once exported, this pSQL script is applied to a clean PostgreSQL database named kds_discovery_2025_template
.
Next, we use dbForge Schema Compare for PostgreSQL to compare this fresh template database with our fully loaded development database, kds_discovery_2025
. This development version contains all the programmable objects—views, functions, stored procedures—that dbdiagram doesn’t track.
The delta script from dbForge adds those programmable components to the clean base. This approach allows us to separate structural design from logic and behavior components, which are maintained in our development environment
We bring everything together with a deployment script: 0065_install_database_2025.sh
.
Here’s what it does:
#!/bin/bash
# Set up variables
dbname="kds_discovery_2025"
ddl_script_dbdiagram="kds_discovery_2025_template.sql"
ddl_script_kds="template_synch.sql"
# Connect to PostgreSQL and apply scripts
psql -h $(hostname) -U postgres <<EOF
CREATE DATABASE $dbname;
\c $dbname;
$(cat "$ddl_script_dbdiagram")\g
$(cat "$ddl_script_kds")\g
...
EOF
It creates the new database, applies both the schema and delta scripts, and loads configuration tables like admin.prompt_type
, reference.industry
, and more.
This ensures that each fresh deployment includes both the structure and the logic needed to run the app.
We chose to deploy the database on a DigitalOcean Droplet. We decided DigitalOcean over AWS, Azure, or Google Cloud for a few reasons:
Instead of using a managed PostgreSQL instance that Digital Ocean offers, we opted for our own install. This gave us more control and avoided some platform-specific limitations.
Here’s the basic setup:
sudo apt install postgresql
postgresql.conf
:
sudo nano /etc/postgresql/16/main/postgresql.conf
Change:
listen_addresses = '*'
pg_hba.conf
:
sudo nano /etc/postgresql/16/main/pg_hba.conf
Add the following line and replace nnn.nnn.nnn.nnn with your IP address
host all all nnn.nnn.nnn.nnn/32 md5
sudo -i -u postgres
psql
ALTER USER postgres WITH PASSWORD 'your_secure_password';
After PostgreSQL is installed and configured, we:
sudo apt install gh
git clone https://github.com/kds-github/data_discovery.git
cd data_discovery
bash 0065_install_database_2025.sh
This bash script sets up the database, loads essential configuration data, and gets the app ready to run. It’s lightweight, repeatable, and simple enough to debug or adjust as the database evolves.
Today we explored our approach deploying the kDS Discovery App's PostgreSQL database on DigitalOcean. By combining structural exports from dbdiagram.io with programmable components from our development environment, we've created a repeatable process that ensures consistency across deployments. This method gives us the control we need while keeping the setup process straightforward and maintainable. In a future post, we'll discuss how to deploy the application server that manages the kDS Discovery App.
Also, don't forget that kDS LLC is actively seeking organizations interested in adopting a beta version of the kDS Data Source Discovery App. If your organization is interested in exploring how our app can streamline your data source discovery process, please let us know. We’d love to collaborate. Tell us in the comments below or email us at info@keeshinds.com
Until next time, thanks for stopping by.